<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue配合Ajax完成数据请求（axios）</title>
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
</head>
<body>
<!--Get请求-->
    <div id="app">
        {{info}}
    </div>
    <script type="text/javascript">
        new Vue({
            el:'#app',
            data(){
                return{
                    info:null
                }
            },
            mounted(){
                axios
                    .get('https://www.runoob.com/try/ajax/json_demo.json')
                    .then(response => (this.info = response))
                    .catch(function (error){
                        alert('Get请求失败！！！')
                    })
            }
        })
    </script>


<!--Post请求-->
<div id="app2">
    {{info}}
</div>
<script type="text/javascript">
    new Vue({
        el:'#app2',
        data(){
            return{
                info:null
            }
        },
        mounted() {
            axios
                .post('https://www.runoob.com/try/ajax/json_demo.json')
                .then(response => (this.info = response))
                .catch(function(error){
                    alert('Post请求失败！')
                });
        }
    })
</script>
</body>
</html>